package com.lyf.scm.common.util.style;

import com.alibaba.excel.metadata.Head;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Workbook;

/**
 * description:
 *
 * @author: haodong
 * @data: 2020/8/29 14:47
 */
public class DirectlyExecuteCellWriterHandler extends PercentageCellWriteHandler {
    public static final int RON_MUN_THREE = 3;
    public static final int TOTAL_TARGET_NUM = 6;

    @Override
    protected void initCellStyle(Workbook workbook) {
        super.initCellStyle(workbook);
    }

    @Override
    protected void setContentCellStyle(Cell cell, Head head, Integer relativeRowIndex) {
        if (MAIN_TITLES.contains(head.getHeadNameList().get(0))) {
            cell.setCellStyle(bodyGeneralCellStyleLeft);
        } else {
            if (cell.getRow().getRowNum() % TOTAL_TARGET_NUM == RON_MUN_THREE  || cell.getRow().getRowNum() % TOTAL_TARGET_NUM == 0) {
                //无效值
                if (cell.getCellTypeEnum().compareTo(CellType.STRING) != 0) {
                    cell.setCellStyle(percentageCellStyle);
                } else {
                    cell.setCellStyle(bodyGeneralCellStyleRight);
                }
            }else{
                cell.setCellStyle(bodyGeneralCellStyleRight);
            }
        }
    }
}
